Interacive spatial maps of the 2024 mass coral bleaching event (click on individual reefs for reef_name / label_ID and maximum DHW exposure during previous events 1998, 2002, 2016, 2017, 2020 & 2022):

library(tidyverse)
library(janitor)
library(sf)
library(stars)
library(raster)
library(tmap)
library(ggplot2)
library(terra)
library(tidyterra)


gbr_shape_dhw <- readRDS("/Users/rof011/GBR-coral-bleaching/data/gbr_shape_dhw.RDS")

gbr_shape_dhw_simple <- gbr_shape_dhw |> 
  st_simplify(preserveTopology = FALSE, dTolerance = 10)


gbr_shape_dhw_map <- gbr_shape_dhw_simple %>%
  mutate(across(where(is.numeric), round, digits = 1))

tmap_mode("view")

  tm_basemap("Esri.WorldImagery") +
  tm_shape(gbr_shape_dhw_map) +
    tm_polygons(col="dhw_max_2024",  title="DHW Max 2024", palette="-RdBu", 
                breaks= seq(0,20,1), alpha=0.8, legend.show=TRUE,
                popup.vars = c("dhw_max_1998", "dhw_max_2002", "dhw_max_2016", 
                    "dhw_max_2017", "dhw_max_2020", "dhw_max_2022", "dhw_max_2024")) + 
    
  tm_view(set.view = c(145.3, -14.5, 10))